package com.dxyusn.schedule.elasticjob.standalone.simple;

import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperConfiguration;
import org.apache.shardingsphere.elasticjob.reg.zookeeper.ZookeeperRegistryCenter;

public class SimpleJobTest
{

	public static void main(String[] args)
	{
		ScheduleJobBootstrap scheduleJobBootstrap = new ScheduleJobBootstrap(createRegistryCenter(), new MySimpleJob(),
				createJobConfiguration());
		scheduleJobBootstrap.schedule();
	}

	private static CoordinatorRegistryCenter createRegistryCenter()
	{
		CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(
				new ZookeeperConfiguration("localhost:2181", "elastic-job"));
		regCenter.init();
		return regCenter;
	}

	private static JobConfiguration createJobConfiguration()
	{
		// 创建作业配置
		JobConfiguration jobConfig = JobConfiguration.newBuilder("MyJob", 4).cron("0/5 * * * * ?").shardingItemParameters("0=RDP, 1=CORE, 2=SIMS, 3=ECIF").failover(true).build();
		return jobConfig;

	}
}
